import { messages, queryCurrencyPrecision } from "share/common";
import React, { Component, PropTypes } from 'react'
import moment from "moment";
import { Divider } from "antd";
import Condition from "components/condition";
const { If } = Condition;

class SlideDocumentHeader extends Component {
  static contextTypes = {
    info: PropTypes.object
  };

  render() {
    const { info = {} } = this.context;
    return (
      <div className='slide-document-header'>
        <span className='slide-document-header-info'>
          {String(info.status).startsWith('1001') ? messages('common-1.key1270')/*修改日期*/ : messages('common.submit.date')/*提交日期*/}：
          {info.lastSubmittedDate || info.submittedDate ?
            moment(info.lastSubmittedDate || info.submittedDate).format('YYYY-MM-DD') :
            moment(info.createdDate).format('YYYY-MM-DD')
          }
        </span>
        <Divider type='vertical'/>
        <span className='slide-document-header-info'>
          {messages('common-1.key1271')/*制单人*/}：
          {info.createdName || (info.applicant ? info.applicant.fullName : '-')}
        </span>
        <If value={info.submittedBy && ((info.applicantOID !== info.submittedBy) || (info.applicant && info.applicant.userOID !== info.submittedBy))}>
          <Divider type='vertical'/>
          <span className='slide-document-header-info'>
            {messages('finance-1.key114')/*代提人*/}：{info.submittedName}
          </span>
        </If>
        <Divider type='vertical'/>
        <span>
          {messages('common.document.code')/*单号*/}：
          {info.parentBusinessCode ? `${info.parentBusinessCode}-` : ''}{info.businessCode}
        </span>
        <If value={String(info.status).startsWith('1001')}>
          <span className="text-info">
            {moment(info.lastModifiedDate).format('YYYY-MM-DD HH:mm')}
            {messages('common-1.key1272')/*单据已保存*/}
          </span>
        </If>
      </div>
    )
  }

}

export default SlideDocumentHeader;
